/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import models.Docente;
import models.SemestreAcademico;
import play.cache.Cache;
import play.libs.Images;
import play.mvc.Controller;
import play.mvc.With;

/**
 *
 * @author Administrador
 */
@With(Secure.class)
public class firstController extends Controller {

    static String username;
    static String periodo;
    static Docente docente;

    public static void dispatcher() {

        username = Security.connected();
        session.clear();
        docente = Docente.find("doc_vcCodigo", username).first();
        periodo = null;

        SemestreAcademico semestre = new SemestreAcademico();
        semestre = SemestreAcademico.find("order by id DESC").first();

        String controler;

        if (username.equals("999999")) {
            controler = "aperturarCiclo.index";
        } else {
            if (semestre != null) {
                periodo = semestre.sem_vcNombre;
                if (username.equals("000000")) {
                    controler = "dptoAcademico.extraerPeriodo";
                } else {
                    controler = "areaDocente.perfilDocente";
                }
            } else {
                controler = "msgPeriodo.mensaje";
            }
        }
        redirect(controler);
    }

    public static void captcha(String id) {
        Images.Captcha captcha = Images.captcha();
        String code = captcha.getText("#E4EAFD");
        Cache.set(id, code, "10mn");
        renderBinary(captcha);
    }
    
    
//    public static void show(Long id) {
//    Post post = Post.findById(id);
//    String randomID = Codec.UUID();
//    render(post, randomID);
//}
}
